from . import db


class User(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    username = db.Column(db.String(80), doc="用户名", unique=True)
    password = db.Column(db.String(256), doc="用户密码")
    email = db.Column(db.String(80), doc="电子邮件", unique=True)
    activation = db.Column(db.Boolean, doc="激活用户", default=True)
    superuser = db.Column(db.Boolean, doc="超级用户", default=False)
    vipuser = db.Column(db.Boolean, doc="vip用户", default=False)
    orders = db.relationship(
        "Order", backref="user", lazy="dynamic", passive_deletes=True, cascade="all, delete"
    )

    def __repr__(self):
        return "<User:%s>" % self.username

    __tablename__ = "f_user"
